#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

/**
 * Definition for a binary tree node.
 */
struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};
typedef struct TreeNode treeNode, *treeNode_ptr;

void flatten(struct TreeNode* root);

int main()
{
	return 0;
}

void flatten(struct TreeNode* root)
{
	treeNode_ptr cur = root;
	while (cur) {
		if (cur->left) {
			treeNode_ptr ptr = cur->left,
						 pred = ptr;
			while (pred->right)
				pred = pred->right;
			pred->right = cur->right;
			cur->left = NULL;
			cur->right = ptr;
		}
		cur = cur->right;
	}
}
